package cn.wizzer.app.web.modules.controllers.platform.user.account;

import cn.wizzer.app.user.modules.models.enums.TransferStatusEnum;
import cn.wizzer.app.user.modules.services.account.UserTransferService;
import cn.wizzer.framework.base.Result;
import com.alibaba.dubbo.config.annotation.Reference;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

/**
 * @author zl
 * @date 2020/6/8 17:37
 */
@IocBean
@At("/platform/user/account/transfer")
public class AccountTransferController {
    private static final Log log = Logs.get();

    @Inject
    @Reference
    private UserTransferService transferService;

    @At("")
    @Ok("beetl:/platform/user/account/transfer/index.html")
    @RequiresPermissions("user.account.transfer")
    public void index() {

    }

    /**
     * 列表
     *
     * @param pageNumber        页码
     * @param pageSize          页数
     * @param no                流水号模糊查询
     * @param transferKeyword   转出人模糊查询（手机号、昵称、用户名）
     * @param collectKeyword    收款人模糊查询（手机号、昵称、用户名）
     * @param searchDate        时间集合
     * @param status            记录状态
     * @return
     */
    @At
    @Ok("json:full")
    @RequiresPermissions("user.account.transfer")
    public Object list(@Param("pageNumber") int pageNumber,
                       @Param("pageSize") int pageSize,
                       @Param("no") String no,
                       @Param("transferKeyword") String transferKeyword,
                       @Param("collectKeyword") String collectKeyword,
                       @Param("searchDate") String[] searchDate,
                       @Param("status") TransferStatusEnum status) {
        return Result.success().addData(transferService.listPage(pageNumber, pageSize, no, transferKeyword, collectKeyword, searchDate, status));
    }

    @At
    @Ok("json:full")
    @RequiresPermissions("user.account.transfer")
    public Object getTransferStatusList() {
        return Result.success().addData(TransferStatusEnum.toList());
    }

}
